package org.alanlau.netty_6;

import org.msgpack.MessagePack;
import org.msgpack.template.Templates;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * MessagePack Java api演示
 *
 * @author alan
 * @version 1.0
 * @date 2021/3/10 23:13
 */
public class MsgPackTest {
    public static void main(String[] args) throws IOException {
        List<String> src = new ArrayList<>();
        src.add("msgpack");
        src.add("kumofs");
        src.add("viver");
        MessagePack msgPack = new MessagePack();
        // Serialize
        byte[] raw = msgPack.write(src);
        // Deserialize directly using a template
        List<String> dst1 = msgPack.read(raw, Templates.tList(Templates.TString));
        System.out.println(dst1.get(0));
        System.out.println(dst1.get(1));
        System.out.println(dst1.get(2));
    }
}
